if ($rowstart == 0) {
$result = dbquery(
"SELECT t.*, COUNT(p.post_id) AS thread_replies, tu1.user_name AS user_author, tu2.user_name AS user_lastuser FROM ".$db_prefix."threads t
LEFT JOIN ".$db_prefix."posts p USING(thread_id)
LEFT JOIN ".$db_prefix."users tu1 ON t.thread_author = tu1.user_id
LEFT JOIN ".$db_prefix."users tu2 ON t.thread_lastuser = tu2.user_id
WHERE t.forum_id='$forum_id' AND thread_sticky='1' GROUP BY thread_id ORDER BY thread_lastpost DESC"
);
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
if ($data['thread_locked']) {
echo "<tr>\n<td align='center' width='25' class='tbl2'><img src='".THEME."forum/folderlock.gif' alt='".$locale['564']."'></td>";
} else {
if ($data['thread_lastpost'] > $lastvisited) {
$folder = "<img src='".THEME."forum/foldernew.gif' alt='".$locale['560']."'>";
} else {
$folder = "<img src='".THEME."forum/folder.gif' alt='".$locale['561']."'>";
}
echo "<tr>\n<td align='center' width='25' class='tbl2'>$folder</td>";
}
$reps = ceil($data['thread_replies'] / $threads_per_page);
$threadsubject = "<a href='".seoname($data['thread_subject'])."-fc".$forum_id."-ft".$data['thread_id'].".htm'>".$data['thread_subject']."</a>";
if ($reps > 1) {
$ctr = 0; $ctr2 = 1; $pages = "";
while ($ctr2 <= $reps) {
$pnum = "<a href='".seoname($data['thread_subject'])."-fc".$forum_id."-ft".$data['thread_id'].".".$ctr.".htm'>$ctr2</a> ";
$pages = $pages.$pnum; $ctr = $ctr + $threads_per_page; $ctr2++;
}
$threadsubject .= " - (".$locale['412'].trim($pages)."

";
}
echo "<td class='tbl1'><img src='".THEME."forum/stickythread.gif' alt='".$locale['560']."' style='vertical-align:middle;'>
$threadsubject</td>